package leetcode;

/**
 * @author Liangyaoyun
 */
public class leetCode74 {
    public boolean searchMatrix(int[][] matrix, int target) {
        //列
        int line=matrix.length-1;
        //行
        int row=matrix[0].length-1;
        int i=0;
        int j=row;
        //从[0][5]开始
        while (i<=line&&j>=0){
            if (matrix[i][j]>target){
                j--;
            }else if (matrix[i][j]<target){
                i++;
            }else if (matrix[i][j]==target){
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        int[][] matrix=new int[][]{{1,3,5,7},{1,3,5,7},{10,11,16,20},{23,30,14,60}};
        int line=matrix.length-1;
        int row=matrix[0].length;
        System.out.println(matrix[line][0]);

    }
}
